package api

import (
	"cap_client/global"
	"github.com/gin-gonic/gin"
	"lib/middleware"
)

func StartHttpServer(apiPrefix string) (err error) {
	app := gin.New()

	aipGroup := app.Group(apiPrefix)
	aipGroup.Use(middleware.HttpLog())
	adminGroup(aipGroup)
	err = app.Run(global.Conf.Http.Addr)
	return err
}

func adminGroup(r *gin.RouterGroup) {
	sub := r.Group("client")

	sub.POST("register", ClientApi.Register)
	sub.POST("uploadCloudApp", ClientApi.UploadCloudApp)
	sub.POST("createRdpWinAccount", ClientApi.CreateRdpWinAccount)
}
